import Vue from 'vue'
import Router from 'vue-router'
import Register from '@/components/Register'
import UserRegister from '@/components/UserRegister'
import RegisterResult from '@/components/RegisterResult'
import Order from '@/components/Order'
import Payment from '@/components/Payment'
import Result from '@/components/Result'
import Agreement from '@/components/Agreement'
import OpenApp from '@/components/OpenApp'
import Login from '@/components/Login'
import ShareStore from '@/components/ShareStore'
import ShareGoods from '@/components/ShareGoods'
import PaymentResult from '@/components/PaymentResult'
import Promotion from '@/components/Promotion'
import TouristOrder from '@/components/TouristOrder'
import TouristPayResult from '@/components/TouristPayResult'
import Activity from '@/components/Activity'
import TopicActivity from '@/components/TopicActivity'
import TyActivity from '@/components/TyActivity'
import GqActivity from '@/components/GqActivity'
import HotStoreActivity from '@/components/HotStoreActivity'
import PrivacyPolicy from '@/components/PrivacyPolicy'
Vue.use(Router)

let router = new Router({
  routes: [
    {
      path: '/',
      name: 'TouristOrder',
      component: TouristOrder
    },
    {
      path: '/register',
      name: 'Register',
      component: Register
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/shareGoods',
      name: 'ShareGoods',
      component: ShareGoods
    },
    {
      path: '/shareStore',
      name: 'ShareStore',
      component: ShareStore
    },
    {
      path: '/order',
      name: 'Order',
      component: Order
    },
    {
      path: '/payment',
      name: 'Payment',
      component: Payment
    },
    {
      path: '/result',
      name: 'Result',
      component: Result
    },
    {
      path: '/paymentResult',
      name: 'PaymentResult',
      component: PaymentResult
    },
    {
      path: '/agreement',
      name: 'Agreement',
      component: Agreement
    },
    {
      path: '/openApp',
      name: 'OpenApp',
      component: OpenApp
    },
    {
      path: '/userRegister',
      name: 'UserRegister',
      component: UserRegister,
      meta: { title: '注册下载' }
    },
    {
      path: '/registerResult',
      name: 'RegisterResult',
      component: RegisterResult
    },
    {
      path: '/promotion',
      name: 'promotion',
      component: Promotion
    },
    {
      path: '/touristPayResult',
      name: 'TouristPayResult',
      component: TouristPayResult
    },
    {
      path: '/activity',
      name: 'Activity',
      component: Activity
    },
    {
      path: '/topicActivity',
      name: 'TopicActivity',
      component: TopicActivity
    },
    {
      path: '/tyActivity',
      name: 'TyActivity',
      component: TyActivity
    },
    {
      path: '/gqActivity',
      name: 'GqActivity',
      component: GqActivity
    },
    {
      path: '/hotStoreActivity',
      name: 'HotStoreActivity',
      component: HotStoreActivity
    },
    {
      path: '/privacyPolicy',
      name: 'PrivacyPolicy',
      component: PrivacyPolicy
    }
  ]
})
const siteName = '壹键哥'
// 设置title
router.beforeEach((to, from, next) => {
  if (to.meta.title && to.path !== '/') {
    document.title = to.meta.title + '-' + siteName
  } else {
    document.title = siteName
  }
  next()
})

export default router
